//
//  main.m
//  MethodsSwizzlingTest
//
//  Created by wangrui on 13-11-27.
//  Copyright (c) 2013年 PPS. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "Bar.h"
#import "Bar+TestCategary.h"
#import "JRSwizzle.h"

int main(int argc, const char * argv[])
{

    @autoreleasepool {
        Foo * foo = [[Foo alloc] init];
        Bar * bar = [[Bar alloc] init];
                     
        NSLog(@"========= Method Swizzling test 1 =========");
        NSLog(@" Step 1");
        [foo testMethod];
        [bar testMethod];
        [bar altTestMethod];
        
        NSLog(@" Step 2");
        [Bar jr_swizzleMethod:@selector(testMethod)
                   withMethod:@selector(altTestMethod)
                        error:nil];
        [foo testMethod];
        [bar testMethod];
        [bar altTestMethod];
                     
                     
        NSLog(@"========= Method Swizzling test 2 =========");
        NSLog(@" Step 1");
        [foo baseMethod];
        [bar baseMethod];
        [bar altBaseMethod];
                     
        NSLog(@" Step 2");
        [Bar jr_swizzleMethod:@selector(baseMethod)
                withMethod:@selector(altBaseMethod)
                        error:nil];
        [foo baseMethod];//这里不会改变foo的method
        [bar baseMethod];
        [bar altBaseMethod];
                     
                     
        NSLog(@"========= Method Swizzling test 3 =========");
        [Bar jr_swizzleMethod:@selector(recursionMethod)
                   withMethod:@selector(altRecusionMethod)
                        error:nil];
        [bar recursionMethod];
        
        /*
         Bar * bar = [[Bar alloc] init];
         [bar testMethod];
         */
    }
    
    return 0;
}

